﻿Imports System.Data.SqlClient

Public Class clsREQUIEREN_ATENCION
    Private mstrDescripcion As String
    Private mintMenu As Integer
    Private mintIdUsuario As Integer
    
    Public Property IdUsuario() As Integer
        Get
            Return mintIdUsuario
        End Get
        Set(ByVal value As Integer)
            mintIdUsuario = value
        End Set
    End Property
    Public Property Menu() As Integer
        Get
            Return mintMenu
        End Get
        Set(ByVal value As Integer)
            mintMenu = value
        End Set
    End Property
    Public Property Descripcion() As String
        Get
            Return mstrDescripcion
        End Get
        Set(ByVal value As String)
            mstrDescripcion = value
        End Set
    End Property
   
    Public Sub New()
        mstrDescripcion = ""
        mintMenu = 0
        mintIdUsuario = 0
    End Sub
    Public Sub Guardar()
        Dim MENU As String = BuscarStrDatoCitra("SELECT MENU FROM REQUIEREN_ATENCION WHERE DESCRIPCION='" & Descripcion & "'")
        If Len(MENU.Trim) = 0 Then
            Insertar()
        End If
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into REQUIEREN_ATENCION (" & _
                            "DESCRIPCION," & _
                            "IDUSUARIO," & _
                            "MENU)" & _
                            "VALUES (" & _
                            "@DESCRIPCION," & _
                            "@IDUSUARIO," & _
                            "@MENU)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("DESCRIPCION", mstrDescripcion)
        Command.Parameters.AddWithValue("IDUSUARIO", mintIdUsuario)
        Command.Parameters.AddWithValue("MENU", mintMenu)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
            If RowsAffected > 0 Then
                cnConn.Close()
            Else
                If cnConn.State = ConnectionState.Open Then
                    cnConn.Close()
                End If
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Aviso")
        End Try


    End Sub
End Class
